<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="#" class="lj" data-index="123">链接</a>
    <img src="" alt="" >
    
</body>
<script>
    const em1 = document.querySelector('.lj');
    console.log(em1.href);
    em1.href = 'http://www/baidu.com';
    em1.textContent = '百度一下';
    em1.setAttribute('href','http://www/mi.com');
    em1.setAttribute('data-index','456');
    console.log(em1.getAttribute('data-index'));
    
</script>
</html>